package com.ych.bean;

/**
 * 统一响应数据格式
 * @param <T>
 */
public class ResponseBean<T> {
    // 响应的状态码
    private Integer code;
    // 响应的消息内容
    private String msg;
    // 响应的具体数据
    private T data;

    // 构成方法


    public ResponseBean(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseBean() {
    }

    public ResponseBean(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseBean(Integer code, String msg, long count, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    // 统一错误的响应
    public static ResponseBean Error(Integer code,String msg){
        return new ResponseBean(code,msg);
    }
    // 统一成功的响应
    public static ResponseBean Success(String msg){
        return new ResponseBean(200,msg);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
